Dynomotion

Group: DynoMotion Message: 13204 From: Colin Fera Date: 4/27/2016
Subject: simple NC touch probe center find
The code below is my first attempt at using an NC touch probe to find the center of a circle and move to it.  Does this look like a viable approach?

Should the touch probe be connected to an opto input?


#include "KMotionDef.h"
#include "PC-DSP.h"

double maxX= 2000*14/16*5*2; // 2000*14/16*5*inchesRadius
double maxY= 2000*14/18*5*2; // 2000*14/18*5*inchesRadius

double Xspeed=1143; // IPS=rot/step*in/rot*rot/rot*step/second = .1/(1/2000*14/16*.2)
double Yspeed=1286; //.1/(1/2000*14/18*.2)


// int GetDROs(double *DROx, double *DROy, double *DROz, double *DROa, double *DROb, double *DROc);
int probeBit=;
double x[3];
double y[3];
double XX;
double YY;



#define X 0                              
#define Y 1                             
#define Z 2   

main()
{
    printf("Starting centerfind X\n");
    x[0] = ch0->Dest;
    y[0] = ch1->Dest;
    Jog(X, Xspeed);
    while(ReadBit(probeBit) && ch0->Dest < x[0] + maxX)
    Jog(X, 0);
    while(!CheckDone(X))
    x[1] = ch0->Dest;
    Jog(X, -Xspeed);
    while(ReadBit(probeBit) && ch0->Dest > x[0] - maxX)
    Jog(X, 0);
    while(!CheckDone(X))
    x[2] = ch0->Dest;
    Move(X, (x[1]-x[2])/2);
    while(ReadBit(probeBit) && !CheckDone(X))
        
    printf("Starting centerfind Y\n");
    
    y[0] = ch1->Dest;
    Jog(Y, Yspeed);
    while(ReadBit(probeBit) && ch1->Dest < y[0] + maxY)
    Jog(Y, 0);
    while(!CheckDone(Y))
    Y[1] = ch1->Dest;
    Jog(Y, -Yspeed);
    while(ReadBit(probeBit) && ch1->Dest > y[0] - maxY)
    Jog(Y, 0);
    while(!CheckDone(Y))
    y[2] = ch1->Dest;
    Move(Y, (y[1]-y[2])/2);
    while(ReadBit(probeBit) && !CheckDone(y))
        
    printf("Finished centerfind \n"); 
}
Group: DynoMotion Message: 13205 From: Tom Kerekes Date: 4/27/2016
Subject: Re: simple NC touch probe center find
Hi Colin,

The probe can be connected to any spare input.  An Opto would be a good choice for noise reasons.

looks reasonable to me except:

while loops should end with a ';'.  Otherwise the next statement or block will be included in the loop.

The center position should be the average of the measured positions not the difference.  (use + not -)

you might want to sample the measured position right where the probe is detected rather than after the deceleration to a stop.  Although if at full speed the deceleration distance would be the same both ways so it wouldn't change the result.

The wait for moves back to center should only wait for the CheckDone() not the probe input

'Y' and 'y' are different things.  The one Move uses 'y' instead of 'Y"

probebit value is missing

XX and YY are never used so should be removed.

HTH
Regards
TK

On 4/27/2016 7:24 AM, Colin Fera colin.fera@... [DynoMotion] wrote:
 
The code below is my first attempt at using an NC touch probe to find the center of a circle and move to it.  Does this look like a viable approach?

Should the touch probe be connected to an opto input?


#include "KMotionDef.h"
#include "PC-DSP.h"

double maxX= 2000*14/16*5*2; // 2000*14/16*5*inchesRadius
double maxY= 2000*14/18*5*2; // 2000*14/18*5*inchesRadius

double Xspeed=1143; // IPS=rot/step*in/rot*rot/rot*step/second = .1/(1/2000*14/16*.2)
double Yspeed=1286; //.1/(1/2000*14/18*.2)


// int GetDROs(double *DROx, double *DROy, double *DROz, double *DROa, double *DROb, double *DROc);
int probeBit=;
double x[3];
double y[3];
double XX;
double YY;



#define X 0                              
#define Y 1                             
#define Z 2   

main()
{
    printf("Starting centerfind X\n");
    x[0] = ch0->Dest;
    y[0] = ch1->Dest;
    Jog(X, Xspeed);
    while(ReadBit(probeBit) && ch0->Dest < x[0] + maxX)
    Jog(X, 0);
    while(!CheckDone(X))
    x[1] = ch0->Dest;
    Jog(X, -Xspeed);
    while(ReadBit(probeBit) && ch0->Dest > x[0] - maxX)
    Jog(X, 0);
    while(!CheckDone(X))
    x[2] = ch0->Dest;
    Move(X, (x[1]-x[2])/2);
    while(ReadBit(probeBit) && !CheckDone(X))
        
    printf("Starting centerfind Y\n");
    
    y[0] = ch1->Dest;
    Jog(Y, Yspeed);
    while(ReadBit(probeBit) && ch1->Dest < y[0] + maxY)
    Jog(Y, 0);
    while(!CheckDone(Y))
    Y[1] = ch1->Dest;
    Jog(Y, -Yspeed);
    while(ReadBit(probeBit) && ch1->Dest > y[0] - maxY)
    Jog(Y, 0);
    while(!CheckDone(Y))
    y[2] = ch1->Dest;
    Move(Y, (y[1]-y[2])/2);
    while(ReadBit(probeBit) && !CheckDone(y))
        
    printf("Finished centerfind \n"); 
}

Group: DynoMotion Message: 13206 From: Colin Fera Date: 4/27/2016
Subject: Re: simple NC touch probe center find
Thanks Tom,

Would it be reasonable to use a button in kmotion CNC to start this in another thread?

Ever since I started using modern IDE's I have gotten so lazy with the syntax that if I try to write something in a text editor I make a bunch of syntax errors.

Colin


On Wed, Apr 27, 2016 at 8:26 AM, Tom Kerekes tk@... [DynoMotion] <DynoMotion@yahoogroups.com> wrote:
 

Hi Colin,

The probe can be connected to any spare input.  An Opto would be a good choice for noise reasons.

looks reasonable to me except:

while loops should end with a ';'.  Otherwise the next statement or block will be included in the loop.

The center position should be the average of the measured positions not the difference.  (use + not -)

you might want to sample the measured position right where the probe is detected rather than after the deceleration to a stop.  Although if at full speed the deceleration distance would be the same both ways so it wouldn't change the result.

The wait for moves back to center should only wait for the CheckDone() not the probe input

'Y' and 'y' are different things.  The one Move uses 'y' instead of 'Y"

probebit value is missing

XX and YY are never used so should be removed.

HTH
Regards
TK



On 4/27/2016 7:24 AM, Colin Fera colin.fera@... [DynoMotion] wrote:
 
The code below is my first attempt at using an NC touch probe to find the center of a circle and move to it.  Does this look like a viable approach?

Should the touch probe be connected to an opto input?


#include "KMotionDef.h"
#include "PC-DSP.h"

double maxX= 2000*14/16*5*2; // 2000*14/16*5*inchesRadius
double maxY= 2000*14/18*5*2; // 2000*14/18*5*inchesRadius

double Xspeed=1143; // IPS=rot/step*in/rot*rot/rot*step/second = .1/(1/2000*14/16*.2)
double Yspeed=1286; //.1/(1/2000*14/18*.2)


// int GetDROs(double *DROx, double *DROy, double *DROz, double *DROa, double *DROb, double *DROc);
int probeBit=;
double x[3];
double y[3];
double XX;
double YY;



#define X 0                              
#define Y 1                             
#define Z 2   

main()
{
    printf("Starting centerfind X\n");
    x[0] = ch0->Dest;
    y[0] = ch1->Dest;
    Jog(X, Xspeed);
    while(ReadBit(probeBit) && ch0->Dest < x[0] + maxX)
    Jog(X, 0);
    while(!CheckDone(X))
    x[1] = ch0->Dest;
    Jog(X, -Xspeed);
    while(ReadBit(probeBit) && ch0->Dest > x[0] - maxX)
    Jog(X, 0);
    while(!CheckDone(X))
    x[2] = ch0->Dest;
    Move(X, (x[1]-x[2])/2);
    while(ReadBit(probeBit) && !CheckDone(X))
        
    printf("Starting centerfind Y\n");
    
    y[0] = ch1->Dest;
    Jog(Y, Yspeed);
    while(ReadBit(probeBit) && ch1->Dest < y[0] + maxY)
    Jog(Y, 0);
    while(!CheckDone(Y))
    Y[1] = ch1->Dest;
    Jog(Y, -Yspeed);
    while(ReadBit(probeBit) && ch1->Dest > y[0] - maxY)
    Jog(Y, 0);
    while(!CheckDone(Y))
    y[2] = ch1->Dest;
    Move(Y, (y[1]-y[2])/2);
    while(ReadBit(probeBit) && !CheckDone(y))
        
    printf("Finished centerfind \n"); 
}


Group: DynoMotion Message: 13207 From: Tom Kerekes Date: 4/27/2016
Subject: Re: simple NC touch probe center find
Hi Colin,

Yes a KMotionCNC button might be used to execute the center find.

You could also do it from within GCode by assigning an MCode to execute the center find.

Regards
TK


On 4/27/2016 11:42 AM, Colin Fera colin.fera@... [DynoMotion] wrote:
 
Thanks Tom,

Would it be reasonable to use a button in kmotion CNC to start this in another thread?

Ever since I started using modern IDE's I have gotten so lazy with the syntax that if I try to write something in a text editor I make a bunch of syntax errors.

Colin


On Wed, Apr 27, 2016 at 8:26 AM, Tom Kerekes tk@... [DynoMotion] <DynoMotion@yahoogroups.com> wrote:
 

Hi Colin,

The probe can be connected to any spare input.  An Opto would be a good choice for noise reasons.

looks reasonable to me except:

while loops should end with a ';'.  Otherwise the next statement or block will be included in the loop.

The center position should be the average of the measured positions not the difference.  (use + not -)

you might want to sample the measured position right where the probe is detected rather than after the deceleration to a stop.  Although if at full speed the deceleration distance would be the same both ways so it wouldn't change the result.

The wait for moves back to center should only wait for the CheckDone() not the probe input

'Y' and 'y' are different things.  The one Move uses 'y' instead of 'Y"

probebit value is missing

XX and YY are never used so should be removed.

HTH
Regards
TK



On 4/27/2016 7:24 AM, Colin Fera colin.fera@... [DynoMotion] wrote:
 
The code below is my first attempt at using an NC touch probe to find the center of a circle and move to it.  Does this look like a viable approach?

Should the touch probe be connected to an opto input?


#include "KMotionDef.h"
#include "PC-DSP.h"

double maxX= 2000*14/16*5*2; // 2000*14/16*5*inchesRadius
double maxY= 2000*14/18*5*2; // 2000*14/18*5*inchesRadius

double Xspeed=1143; // IPS=rot/step*in/rot*rot/rot*step/second = .1/(1/2000*14/16*.2)
double Yspeed=1286; //.1/(1/2000*14/18*.2)


// int GetDROs(double *DROx, double *DROy, double *DROz, double *DROa, double *DROb, double *DROc);
int probeBit=;
double x[3];
double y[3];
double XX;
double YY;



#define X 0                              
#define Y 1                             
#define Z 2   

main()
{
    printf("Starting centerfind X\n");
    x[0] = ch0->Dest;
    y[0] = ch1->Dest;
    Jog(X, Xspeed);
    while(ReadBit(probeBit) && ch0->Dest < x[0] + maxX)
    Jog(X, 0);
    while(!CheckDone(X))
    x[1] = ch0->Dest;
    Jog(X, -Xspeed);
    while(ReadBit(probeBit) && ch0->Dest > x[0] - maxX)
    Jog(X, 0);
    while(!CheckDone(X))
    x[2] = ch0->Dest;
    Move(X, (x[1]-x[2])/2);
    while(ReadBit(probeBit) && !CheckDone(X))
        
    printf("Starting centerfind Y\n");
    
    y[0] = ch1->Dest;
    Jog(Y, Yspeed);
    while(ReadBit(probeBit) && ch1->Dest < y[0] + maxY)
    Jog(Y, 0);
    while(!CheckDone(Y))
    Y[1] = ch1->Dest;
    Jog(Y, -Yspeed);
    while(ReadBit(probeBit) && ch1->Dest > y[0] - maxY)
    Jog(Y, 0);
    while(!CheckDone(Y))
    y[2] = ch1->Dest;
    Move(Y, (y[1]-y[2])/2);
    while(ReadBit(probeBit) && !CheckDone(y))
        
    printf("Finished centerfind \n"); 
}